//
//  BEResultExtension.swift
//  BasicExtensions
//
//  Created by Fanxx on 2018/3/23.
//  Copyright © 2018年 fanxx. All rights reserved.
//

import UIKit

extension Result {
    ///成功操作
    @discardableResult
    public func success(_ action: (Success) -> Void) -> Self {
        switch self {
        case let .success(value): action(value)
        default: break
        }
        return self
    }
    ///失败操作
    @discardableResult
    public func failure(_ action: (Error) -> Void) -> Self {
        switch self {
        case let .failure(error): action(error)
        default: break
        }
        return self
    }
}
